# 需要用到smtplib模块
import smtplib
# 需要登录QQ邮箱
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# 需要登录qq邮箱
from_add = "2660500960@qq.com"
# 需要输入的授权码
code = "zhysdgunowmadiah"
# qq服务器
stmp_server = "smtp.qq.com"

# 定义邮件信息
# 实例化邮件对象
msgRoot = MIMEMultipart('related')
# 添加邮件发件人
msgRoot["Frome"] = '2660500960@qq.com'
# 添加显示的邮件收件人
msgRoot['To'] = "，".join(["zl13260676137@163.com","2660500960@qq.com"])
# 添加邮件标题
msgRoot['Subject'] = "web自动化测试报告"
# 定义邮件正文
msgText = MIMEText("web自动化报告")
# 添加邮件标题
msgRoot.attach(msgText)

# 添加附件
att = MIMEText(open("./report/report.html",'rb').read(),'base64','utf-8')
att["Content-Type"] = 'application/octet-stream'
# 附件名称
att["Content-Disposition"]='attachment{}'.format("report.html")
msgRoot.attach(att)

# 发送邮件
# 实例化服务器
server = smtplib.SMTP(stmp_server,25)
# 登录邮件服务器
server.login(from_add,code)
# 发送邮件
server.sendmail(from_add,["zl13260676137@163.com","2660500960@qq.com"],msgRoot.as_string())





